package com.hackintosh.shopping;

import java.util.ArrayList;
import java.util.List;

/**
 * @description：袋子
 * @author：twislyn
 * @date：Created in 2021/05/15
 * @modified By：
 * @version: 1.0
 */
public class Bag implements Article {
    private String name;

    private List<Article> bag = new ArrayList<>();

    public Bag(String name) {
        this.name = name;
    }

    public void add(Article article) {
        bag.add(article);
    }

    public void remove(Article article) {
        bag.remove(article);
    }

    @Override
    public float calculate() {
        float price = 0;
        for (Article article : bag) {
            price += article.calculate();
        }
        return price;
    }

    @Override
    public void show() {
        for (Article article : bag) {
            article.show();
        }
    }
}
